package com.wnxy;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.rules.DateType;

import java.util.Collections;

public class CodeGenerator {

    public static void main(String[] args) {

        //修改url username password
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/woniubook?serverTimezone=Asia/Shanghai",
                        "root", "root")

                .globalConfig(builder -> {
                    builder.author("Jet") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .dateType(DateType.ONLY_DATE).disableOpenDir()
                            .outputDir("C:\\class\\workspace\\_7000\\booksys\\booksys-generator\\src\\main\\java"); // 指定输出目录
                }).packageConfig(builder -> {
                    builder.parent("com.wnxy.portal") // 设置父包名
                            .moduleName(null) // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml,
                                    "C:\\class\\workspace\\_7000\\booksys\\booksys-generator\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
                }).strategyConfig(builder -> {
                    builder.entityBuilder().enableLombok();
                    builder.controllerBuilder().enableHyphenStyle().enableRestStyle();
                    builder.addInclude("t_address", "t_book", "t_bookcollection",
                                    "t_booktype", "t_china","t_comment","t_item",
                                    "t_manager","t_manager_role","t_order","t_role",
                                    "t_role_url_permission","t_url_permission","t_user") // 设置需要生成的表名
                            .addTablePrefix("t_"); // 设置过滤表前缀

                })
                .execute();
    }
}
